<!-- Tommy -->
<title>项目设定</title>

<link rel="stylesheet" href="lib/assets/css/jquery-ui.custom.css"/>
<link rel="stylesheet" href="lib/assets/css/daterangepicker.css"/>
<link rel="stylesheet" href="lib/assets/css/datepicker.css"/>
<link rel="stylesheet" href="lib/assets/css/chosen.css" />
<link rel="stylesheet" href="css/align.css" />

<div class="page-header">
    <h1>
        日报设定
        <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
            项目设定
        </small>
    </h1>
</div><!-- /.page-header -->

<div class="row holyContainer" data-ng-controller="pageContentController">
    <div class="col-xs-12">
        <!-- PAGE CONTENT BEGINS -->
        <!-- 查询表格-->
        <div class="widget-box">
            <div class="widget-header">
                <h4 class="widget-title">查询条件</h4>
            </div>

            <div class="widget-body" style="display: block;">
                <div class="widget-main" data-ng-controller="searchFormController">
                    <form method="get" name="searchForm"
                          data-ng-submit="submitSearchForm('1')" novalidate>
                        <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-10 col-md-push-1 col-lg-8 col-lg-push-2">
                                <div class="space space-4"></div>
                                <label for="dateRange-in-searchForm">日期</label>

                                <div class="input-group">
                                            <span class="input-group-addon">
                                                <i class="fa fa-calendar bigger-110"></i>
                                            </span>

                                    <input class="form-control  text-center" type="text"
                                           name="dateRange" id="dateRange-in-searchForm"
                                           data-ng-model="searchFormData.dateRange"
                                           data-ng-change="updateSearchFormRange()" readonly/>
                                </div>
                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <div class="row">

                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1 col-lg-4 col-lg-push-2">
                                <div class="space space-4"></div>
                                <label>项目名</label>
                                <input name="projName" type="text" id="projName-in-searchForm"
                                       value="*"
                                       class="form-control" onfocus="if (value =='*'){value =''}"
                                       onblur="if (value ==''){value='*'}"
                                       data-ng-model="searchFormData.projName"/>

                                <div class="space space-4"></div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1 col-lg-4 col-lg-push-2">
                                <div class="space space-4"></div>
                                <label>项目编码</label>
                                <input name="projNo" type="text" id="projNo-in-searchForm"
                                       value="*"
                                       class="form-control" onfocus="if (value =='*'){value =''}"
                                       onblur="if (value ==''){value='*'}"
                                       data-ng-model="searchFormData.projNo"/>

                                <div class="space space-4"></div>
                            </div>
                        </div>


                        <!-- 按钮 -->
                        <div class="row">
                            <div class="col-xs-12 col-md-pull-1 col-lg-pull-2">
                                <div class="space space-4"></div>
                                <input type="button" class="btn btn-xs pull-right"
                                       data-ng-click="setDefaultSearchFormData()" value="重置"/>
                                <input type="submit" class="btn btn-primary btn-xs pull-right" value="搜索"/>
                                <!-- TODO  -->
                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <!-- /按钮 -->

                    </form>

                </div>
            </div>
        </div>
        <!-- /查询表格-->
        <!-- 分界线 -->
        <div class="hr hr-double hr-dotted hr10"></div>
        <!-- /分界线 -->
        <!-- 结果表格 -->
        <div data-ng-controller="resultTableController" data-ng-show="resultTableData" data-ng-cloak>
            <div class="col-xs-12 col-sm-6 col-md-5 col-lg-4" style="padding: 0px">
                <div class="input-group">
                        <span id="searchInResultToggle" class="input-group-addon"><i
                                class="ace-icon fa fa-search"></i></span>
                    <input id="searchInResult" type="text" class="form-control" placeholder="在结果中搜索"
                           data-ng-model="searchInResult"/> <!-- TODO style -->
                </div>
            </div>
            <table id="resultTable" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th data-ng-repeat="(reference, displayName) in resultTableData.tableHead">
                        {{displayName}}
                    </th>
                    <th>
                        配置
                    </th>
                    
                    <th>
                        <button class="btn btn-xs btn-success"
                                data-ng-click="createModal('add','')">
                            <i class="ace-icon fa fa-plus bigger-120"></i>
                        </button>
                    </th>
                    
                </tr>
                </thead>

                <tbody>
                <tr data-ng-repeat="row in resultTableData.tableRow | filter: searchInResult"
                    data-row-id="{{row[resultTableData.identity]}}">
                    <td data-ng-repeat="(key,value) in row" data-ng-if="key != resultTableData.identity">
                        {{value}}
                    </td>
                    <th>
                        <button class="btn btn-xs btn-success"
                                data-ng-click="createModal('prp',row[resultTableData.identity])">
                            PRP阶段
                        </button>

                         <button class="btn btn-xs btn-info config_dep_btn" data-ng-click="config_dep(row[resultTableData.identity])">
                            部门
                        </button>

                        <button class="btn btn-xs btn-danger"  data-ng-click="createModal('emp',row[resultTableData.identity])">
                            负责人
                        </button>
                    </th>
                    <td>
                        <div class="hidden-sm hidden-xs btn-group">
                            <button class="btn btn-xs btn-success"
                                    data-ng-click="createModal('view',row[resultTableData.identity])">
                                <i class="ace-icon fa fa-search-plus bigger-120"></i>
                            </button>

                            <button class="btn btn-xs btn-info"
                                    data-ng-click="createModal('edit',row[resultTableData.identity])">
                                <i class="ace-icon fa fa-pencil bigger-120"></i>
                            </button>

                            <button class="btn btn-xs btn-danger"
                                    data-ng-click="createModal('del',row[resultTableData.identity])">
                                <i class="ace-icon fa fa-trash-o bigger-120"></i>
                            </button>

                        </div>

                        <div class="hidden-md hidden-lg">
                            <div class="inline pos-rel">
                                <button class="btn btn-minier btn-primary dropdown-toggle"
                                        data-toggle="dropdown"
                                        data-position="auto">
                                    <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                </button>

                                <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                    <li>
                                        <a href="#" class="tooltip-info" data-rel="tooltip" title="View"
                                           data-ng-click="createModal('view',row[resultTableData.identity])">
													<span class="blue">
														<i class="ace-icon fa fa-search-plus bigger-120"></i>
													</span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="#" class="tooltip-success" data-rel="tooltip" title="Edit"
                                           data-ng-click="createModal('edit',row[resultTableData.identity])">
													<span class="green">
														<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
													</span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="#" class="tooltip-error" data-rel="tooltip" title="Delete"
                                           data-ng-click="createModal('edit',row[resultTableData.identity])">
													<span class="red">
														<i class="ace-icon fa fa-trash-o bigger-120"></i>
													</span>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </td>
                </tr>

                </tbody>
            </table>
            <div class="col-xs-12 col-sm-8 col-sm-push-2 col-md-6 col-md-push-3 col-lg-4 col-lg-push-4 center"
                 style="padding: 0px" data-ng-show="!(resultTableData.totalPageNumber == '1')">
                <ul class="pagination" style="margin: 0">
                    <li data-ng-repeat=" number in resultTableData.pageNumberArray"
                        data-ng-class="{'active' : number == resultTableData.pageNumber}"><a
                            data-ng-click="getResultByPage(number)">{{number}}</a></li>
                    <li class="disabled"><a>总记录：{{resultTableData.totalRowNumber}} 条</a></li>
                </ul>
            </div>

        </div>
        <!-- /结果表格 -->
        <!-- Modal -->
        <div class="modal fade" id="modal" tabindex="-1" role="dialog" data-ng-controller="modalController">
            <div class="modal-dialog" role="document">


                <!-- view modal -->
                <div class="modal-content" data-ng-show="modal.modalType == 'view'">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">查看项目详细信息</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">

                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>项目ID</label>
                                <input name="projId" type="text"
                                       class="form-control" data-ng-model="modal.modelData.projId" readonly/>

                                <div class="space space-4"></div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>项目编码</label>
                                <input name="projNo" type="text"
                                       class="form-control" data-ng-model="modal.modelData.projNo" readonly/>

                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>项目名</label>
                                <input name="projName" type="text"
                                       class="form-control" data-ng-model="modal.modelData.projName" readonly/>

                                <div class="space space-4"></div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>状态</label>
                                <select name="parentMenu" class="form-control"
                                        data-ng-model="modal.modelData.state"
                                        data-ng-options=" state.value as state.displayName for state in modal.modelRange.stateRange"
                                        disabled="">
                                </select>

                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>开始日期</label>

                                <div class="input-group">
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                    <input name="startDate" class="form-control date-picker" type="text"
                                           data-date-format="yyyy-mm-dd" data-ng-model="modal.modelData.startDate"
                                           disabled/>
                                </div>
                                <div class="space space-4"></div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>结束日期</label>

                                <div class="input-group">
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                    <input name="endDate" class="form-control date-picker" type="text"
                                           data-date-format="yyyy-mm-dd" data-ng-model="modal.modelData.endDate"
                                           disabled/>
                                </div>
                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <div class="row">

                            <div class="col-xs-12 col-sm-12 col-md-10 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>项目描述</label>
                                <input name="projDescription" type="text"
                                       class="form-control" data-ng-model="modal.modelData.projDescription" readonly/>

                                <div class="space space-4"></div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">

                        <input type="button" class="btn btn-default" data-dismiss="modal" value="关闭">
                    </div>
                </div>
                <!-- /view modal -->
                <!-- edit modal -->
                <div class="modal-content" data-ng-show="modal.modalType == 'edit'">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">修改这个项目</h4>
                    </div>
                    <form name="editModalForm" novalidate>
                    <div class="modal-body">
                        <div class="row">

                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>项目ID</label>
                                <input name="projId" type="text"
                                       class="form-control" data-ng-model="modal.modelData.projId" readonly/>

                                <div class="space space-4"></div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1" data-ng-class="{'has-error' : editModalForm.projNo.$invalid && editFormShowInvalidInfo }">
                                <div class="space space-4"></div>
                                <label>项目编码</label>
                                <input name="projNo" type="text"
                                       class="form-control" data-ng-model="modal.modelData.projNo" required/>
                                <p data-ng-show="editModalForm.projNo.$invalid && editFormShowInvalidInfo"
                                   class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                    <small>项目编码未填写</small>
                                </p>
                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1" data-ng-class="{'has-error' : editModalForm.projName.$invalid && editFormShowInvalidInfo }">
                                <div class="space space-4"></div>
                                <label>项目名</label>
                                <input name="projName" type="text"
                                       class="form-control" data-ng-model="modal.modelData.projName" required/>
                                <p data-ng-show="editModalForm.projName.$invalid && editFormShowInvalidInfo"
                                   class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                    <small>项目名未填写</small>
                                </p>
                                <div class="space space-4"></div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1" data-ng-class="{'has-error' : editModalForm.state.$invalid && editFormShowInvalidInfo }">
                                <div class="space space-4"></div>
                                <label>状态</label>
                                <select name="state" class="form-control"
                                        data-ng-model="modal.modelData.state"
                                        data-ng-options=" state.value as state.displayName for state in modal.modelRange.stateRange" required>
                                </select>
                                <p data-ng-show="editModalForm.state.$invalid && editFormShowInvalidInfo"
                                   class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                    <small>状态未选取</small>
                                </p>
                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>开始日期</label>

                                <div class="input-group">
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                    <input name="startDate" class="form-control date-picker" type="text"
                                           data-date-format="yyyy-mm-dd" data-ng-model="modal.modelData.startDate"
                                           value="{{modal.modelData.startDate}}" readonly required/>
                                </div>
                                <p data-ng-show="editModalForm.startDate.$invalid && editFormShowInvalidInfo"
                                   class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                    <small>开始日期未选取</small>
                                </p>
                                <div class="space space-4"></div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>结束日期</label>

                                <div class="input-group">
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                    <input name="endDate" class="form-control date-picker" type="text"
                                           data-date-format="yyyy-mm-dd" data-ng-model="modal.modelData.endDate"
                                           value="{{modal.modelData.endDate}}" readonly required/>
                                </div>
                                <p data-ng-show="editModalForm.endDate.$invalid && editFormShowInvalidInfo"
                                   class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                    <small>结束日期未选取</small>
                                </p>
                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <div class="row">

                            <div class="col-xs-12 col-sm-12 col-md-10 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>项目描述</label>
                                <input name="projDescription" type="text"
                                       class="form-control" data-ng-model="modal.modelData.projDescription"/>

                                <div class="space space-4"></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="space space-4"></div>
                                <div class="alert alert-danger" role="alert"
                                     data-ng-if="editFormShowResult">
                                    <h4>提交的修改：</h4>

                                    <div class="row">
                                        <div class="col-xs-12">
                                            <div data-ng-repeat="(k,v) in modal.modelData">
                                                <div data-ng-if=" modalOriginal.modelData[k]!=modal.modelData[k] ">
                                                    <p>{{k}}: {{modalOriginal.modelData[k]}} >> {{v}}
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <input type="button" class="btn btn-primary"
                               data-ng-click="submitEditModal(editModalForm.$valid)" value="确认">

                        <input type="button" class="btn btn-default" data-dismiss="modal" value="关闭">
                    </div>
                        </form>

                </div>
                <!-- /edit modal -->
                <!-- add modal -->
                <div class="modal-content" data-ng-show="modal.modalType == 'add'">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">添加一个新的项目</h4>
                    </div>
                    <form name="addModalForm" novalidate>
                        <div class="modal-body">
                            <div class="row">

                                <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                    <div class="space space-4"></div>
                                    <label>项目ID</label>
                                    <input name="projId" type="text"
                                           class="form-control" value="自动生成" disabled/>

                                    <div class="space space-4"></div>
                                </div>
                                <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1" data-ng-class="{'has-error' : addModalForm.projNo.$invalid && addFormShowInvalidInfo }">
                                    <div class="space space-4"></div>
                                    <label>项目编码</label>
                                    <input name="projNo" type="text"
                                           class="form-control" data-ng-model="modal.modelData.projNo" required/>
                                    <p data-ng-show="addModalForm.projNo.$invalid && addFormShowInvalidInfo"
                                       class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                        <small>项目编码未填写</small>
                                    </p>
                                    <div class="space space-4"></div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1" data-ng-class="{'has-error' : addModalForm.projName.$invalid && addFormShowInvalidInfo }">
                                    <div class="space space-4"></div>
                                    <label>项目名</label>
                                    <input name="projName" type="text"
                                           class="form-control" data-ng-model="modal.modelData.projName" required/>
                                    <p data-ng-show="addModalForm.projName.$invalid && addFormShowInvalidInfo"
                                       class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                        <small>项目名未填写</small>
                                    </p>
                                    <div class="space space-4"></div>
                                </div>
                                <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1" data-ng-class="{'has-error' : addModalForm.state.$invalid && addFormShowInvalidInfo }">
                                    <div class="space space-4"></div>
                                    <label>状态</label>
                                    <select name="state" class="form-control"
                                            data-ng-model="modal.modelData.state"
                                            data-ng-options=" state.value as state.displayName for state in modal.modelRange.stateRange" required>
                                    </select>
                                    <p data-ng-show="addModalForm.state.$invalid && addFormShowInvalidInfo"
                                       class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                        <small>状态未选取</small>
                                    </p>
                                    <div class="space space-4"></div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1" data-ng-class="{'has-error' : addModalForm.startDate.$invalid && addFormShowInvalidInfo }">
                                    <div class="space space-4"></div>
                                    <label>开始日期</label>

                                    <div class="input-group">
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                        <input name="startDate" class="form-control date-picker" type="text"
                                               data-date-format="yyyy-mm-dd" data-ng-model="modal.modelData.startDate"
                                               value="{{modal.modelData.startDate}}" readonly required/>
                                    </div>
                                    <p data-ng-show="addModalForm.startDate.$invalid && addFormShowInvalidInfo"
                                       class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                        <small>开始日期未选取</small>
                                    </p>
                                    <div class="space space-4"></div>
                                </div>
                                <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1" data-ng-class="{'has-error' : addModalForm.endDate.$invalid && addFormShowInvalidInfo }">
                                    <div class="space space-4"></div>
                                    <label>结束日期</label>

                                    <div class="input-group">
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                        <input name="endDate" class="form-control date-picker" type="text"
                                               data-date-format="yyyy-mm-dd" data-ng-model="modal.modelData.endDate"
                                               value="{{modal.modelData.endDate}}" readonly required/>
                                    </div>
                                    <p data-ng-show="addModalForm.endDate.$invalid && addFormShowInvalidInfo"
                                       class="help-block"><i class="ace-icon fa fa-angle-up"></i>
                                        <small>结束日期未选取</small>
                                    </p>
                                    <div class="space space-4"></div>
                                </div>
                            </div>
                            <div class="row">

                                <div class="col-xs-12 col-sm-12 col-md-10 col-md-push-1">
                                    <div class="space space-4"></div>
                                    <label>项目描述</label>
                                    <input name="projDescription" type="text"
                                           class="form-control" data-ng-model="modal.modelData.projDescription"/>

                                    <div class="space space-4"></div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-12">
                                    <div class="space space-4"></div>
                                    <div class="alert alert-danger" role="alert"
                                         data-ng-if="addFormShowResult">
                                        <h4>提交的修改：</h4>

                                        <div class="row">
                                            <div class="col-xs-12">
                                                <div data-ng-repeat="(k,v) in modal.modelData">
                                                    <div data-ng-if=" modalOriginal.modelData[k]!=modal.modelData[k] ">
                                                        <p>{{k}}: {{modalOriginal.modelData[k]}} >> {{v}}
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="button" class="btn btn-primary"
                                   data-ng-click="submitAddModal(addModalForm.$valid)" value="确认">

                            <input type="button" class="btn btn-default" data-dismiss="modal" value="关闭">
                        </div>
                    </form>
                </div>
                <!-- /add modal -->
                <!-- del modal -->
                <div class="modal-content" data-ng-show="modal.modalType == 'del'">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">删除这个项目</h4>
                    </div>
                    <div class="modal-body">

                        <div class="row" data-ng-repeat="(k,v) in modal.modelData">
                            <div class="col-xs-12">
                                {{k}} : {{v}}
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <input type="button" class="btn btn-primary"
                               data-ng-click="submitDelModal()" value="确认">

                        <input type="button" class="btn btn-default" data-dismiss="modal" value="关闭">
                    </div>
                </div>
                <!-- /del modal -->
                <!-- special modals -->
                <!-- prp modal -->
                <div class="modal-content" data-ng-show="modal.modalType == 'prp'">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">配置PRP阶段</h4>
                    </div>
                    <div class="modal-body">
                        <div class="col-xs-12" style="padding: 0px">
                            <div class="input-group">
                            <span id="searchInResultToggle2" class="input-group-addon"><i
                                    class="ace-icon fa fa-search"></i></span>
                                <input id="searchInResult2" type="text" class="form-control" placeholder="在结果中搜索"
                                       data-ng-model="searchInResult"/> <!-- TODO style -->
                            </div>
                        </div>
                        <table id="prpSelectTable" class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th data-ng-repeat="(reference, displayName) in modal.modelRange.tableHead">
                                    {{displayName}}
                                </th>
                            </tr>
                            </thead>

                            <tbody>
                            <tr data-ng-repeat="row in modal.modelRange.tableRow | filter: searchInResult"
                                data-row-id="{{row[modal.modelRange.identity]}}">


                                <td class="center">
                                    <label class="pos-rel">
                                        <input type="checkbox" class="ace ace-switch ace-switch-6"
                                               data-ng-model="modal.modelData.selectedRow[row[modal.modelRange.identity]]"/>
                                        <span class="lbl"></span>
                                    </label>
                                </td>

                                <td data-ng-repeat="(key,value) in row " data-ng-if="key != modal.modelRange.identity">
                                    {{value}}
                                </td>

                            </tr>

                            </tbody>
                        </table>


                    </div>
                    <div class="modal-footer">

                        <input type="button" class="btn btn-primary"
                               data-ng-click="submitPRPSelectModal()" value="确认">

                        <input type="button" class="btn btn-default" data-dismiss="modal" value="关闭">

                    </div>
                </div>
                <!-- /prp modal -->
                <!-- empList modal -->
                <div class="modal-content" data-ng-show="modal.modalType == 'emp'">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">配置人员</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>项目经理</label>
                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员"  data-ng-model="modal.modelData.pm"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
                                 
                                </select>
                                <div class="space space-4"></div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
                                <div class="space space-4"></div>
                                <label>质量负责人</label>
                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员"  data-ng-model="modal.modelData.qa"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
                                    
                                </select>
                                <div class="space space-4"></div>
                            </div>
                            
                          </div>
                            <div class="row">
	                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
	                                <div class="space space-4"></div>
	                                <label>研发负责人</label>
	                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员"  data-ng-model="modal.modelData.dp"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
	                                 
	                                </select>
	                                <div class="space space-4"></div>
	                            </div>
	                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
	                                <div class="space space-4"></div>
	                                <label>财务负责人</label>
	                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员"  data-ng-model="modal.modelData.cp"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
	                                    
	                                </select>
	                                <div class="space space-4"></div>
	                            </div>
                            </div>
                            <div class="row">
	                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
	                                <div class="space space-4"></div>
	                                <label>法律/认证</label>
	                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员" data-ng-model="modal.modelData.la"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
	                                   
	                                </select>
	                                <div class="space space-4"></div>
	                            </div>
	                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
	                                <div class="space space-4"></div>
	                                <label>市场负责人</label>
	                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员" data-ng-model="modal.modelData.mp"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
	                                    
	                                </select>
	                                <div class="space space-4"></div>
	                            </div>
                            </div>
                            <div class="row">

	                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
	                                <div class="space space-4"></div>
	                                <label>验证负责人</label>
	                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员" data-ng-model="modal.modelData.vp"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
	                                    
	                                </select>
	                                <div class="space space-4"></div>
	                            </div>
	                          
                            </div>
                            <div class="row">
	                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
	                                <div class="space space-4"></div>
	                                <label>生产负责人</label>
	                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员" data-ng-model="modal.modelData.pp"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange"  >
	                                    
	                                </select>
	                                <div class="space space-4"></div>
	                            </div>
	                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
	                                <div class="space space-4"></div>
	                                <label>应用负责人</label>
	                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员" data-ng-model="modal.modelData.ap"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
	                                   
	                                </select>
	                                <div class="space space-4"></div>
	                            </div>
	                         </div>
	                         <div class="row">
		                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
		                                <div class="space space-4"></div>
		                                <label>采购负责人</label>
		                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员" data-ng-model="modal.modelData.bp"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
		                                    
		                                </select>
		                                <div class="space space-4"></div>
		                            </div>
		                            <div class="col-xs-12 col-sm-6 col-md-5 col-md-push-1">
		                                <div class="space space-4"></div>
		                                <label>服务负责人</label>
		                                <select chosen options="modal.modelRange.empIdRange" class="form-control" data-placeholder="选择人员" data-ng-model="modal.modelData.sp"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
		                                  
		                                </select>
		                                <div class="space space-4"></div>
		                            </div>
		                      </div>
		                 
                       
                        <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-10 col-md-push-1">
                            <label>参与人员</label>
                            <select chosen options="modal.modelRange.empIdRange" multiple class="form-control tag-input-style" data-placeholder="选择多个参与人员" data-ng-model="modal.modelData.tp"
                                            data-ng-options=" person.value as person.displayName for person in modal.modelRange.empIdRange" >
                                
                            </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="space space-4"></div>
                                <div class="alert alert-danger" role="alert"
                                     data-ng-if="editFormShowResult">
                                    <h4>提交的修改：</h4>

                                    <div class="row">
                                        <div class="col-xs-12">
                                            <div data-ng-repeat="(k,v) in modal.modelData">
                                                <div data-ng-if=" modalOriginal.modelData[k]!=modal.modelData[k] ">
                                                    <p>{{k}}: {{modalOriginal.modelData[k]}} >> {{v}}
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    
              
                </div>
                 <div class="modal-footer">
                        <input type="button" class="btn btn-primary"
                               data-ng-click="submitEmpSelectModal()" value="确认">

                        <input type="button" class="btn btn-default" data-dismiss="modal" value="关闭">
                    </div>
                <!-- /empList modal -->
                <!-- /special modals -->
            </div>
        </div>
        <!-- PAGE CONTENT ENDS -->
    </div>
    <!-- /.col -->
</div><!-- /.row -->
</div>


<!-- 配置部门Modal -->
<div class="modal-content col-xs-5 vertical-center config_dep_modal">
	<h4 class="modal-title ng-binding" id="modalLabel">配置部门信息</h4>
	<div class="modal-body">
		<div class="widget-body">
				<div class="widget-main padding-8">
					<ul id="department-treeview"></ul>
				</div>
		</div>
		<div class="modal-footer">
				<button type="button" class="btn btn-primary dep_congfig_submit_btn">提交</button>
				<button type="button" class="btn btn-default dep_congfig_close_btn">关闭</button>
		</div>
	</div>
</div>

<script type="text/javascript">
	$(function(){
		$(".config_dep_modal").css("display","none");		
	})
</script>

<!-- page specific plugin scripts -->
<script type="text/javascript">

    var scripts = [null,"lib/assets/js/jquery.autosize.js","lib/assets/js/chosen.jquery.js","lib/assets/js/date-time/bootstrap-datepicker.js", "lib/assets/js/date-time/moment.js", "lib/assets/js/date-time/daterangepicker.js", "lib/assets/js/jquery.knob.js", "lib/assets/js/jquery.autosize.js", null]
    $('.page-content-area').ace_ajax('loadScripts', scripts, function () {
        //inline scripts related to this page
        jQuery(function ($) {
            //Date Picker
            $('.date-picker').daterangepicker({
                format: 'YYYY-MM-DD',
                singleDatePicker: true,
                showDropdowns: true,
                'applyClass': 'btn-sm btn-success',
                'cancelClass': 'btn-sm btn-default',
                locale: {
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                    firstDay: 1
                }
            }).prev().on('click', function () {
                $(this).next().focus();

            });

            //Date Range Picker
            $('input[name=dateRange]').daterangepicker({
                'applyClass': 'btn-sm btn-success',
                'cancelClass': 'btn-sm btn-default',
                format: 'YYYY-MM-DD',

                locale: {
                    applyLabel: '选择',
                    cancelLabel: '取消',
                    fromLabel: '从',
                    toLabel: '到',
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                    firstDay: 1
                }
            }).prev().on('click', function () {
                $(this).next().focus();
            });

        });
        var loadDatePicker = function () {
            $('.date-picker').daterangepicker({
                format: 'YYYY-MM-DD',
                singleDatePicker: true,
                showDropdowns: true,
                'applyClass': 'btn-sm btn-success',
                'cancelClass': 'btn-sm btn-default',
                locale: {
                    applyLabel: '选择',
                    cancelLabel: '取消',
                    fromLabel: '从',
                    toLabel: '到',
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                    firstDay: 1
                }
            }).prev().on('click', function () {
                $(this).next().focus();

            });
        };
        //chosen
      
        

        //AngularJS
        var app = angular.module('contentApp');
        var messageHandler = function (data) {
            if (data["returnMessage"] != null && data["returnMessage"] != undefined) {
                if (data["returnMessage"].messageType == 'error') {
                    data["returnMessage"].messageType = 'danger';
                }
                $.bootstrapGrowl(data.returnMessage.message, {
                    type: data.returnMessage.messageType, // (null, 'info', 'error', 'success')
                    offset: {from: 'top', amount: 50}, // 'top', or 'bottom'
                    align: 'right', // ('left', 'right', or 'center')
                    width: 250, // (integer, or 'auto')
                    delay: function (type) {
                        if (type == 'error') {
                            return 7000;
                        } else {
                            return 3000;
                        }
                    }(data.returnMessage.messageType),
                    allow_dismiss: true,
                    stackup_spacing: 10 // spacing between consecutively stacked growls.
                });
            }
            return data;
        };
        var servletLocation = "servlet/ProjectServlet";
        //页面控制器
        app.controller("pageContentController", function ($scope) {
            $scope.$on("TableResultUpdateTOParent", function (event, msg) {
                $scope.$broadcast("TableResultUpdate", msg);
            });
            $scope.$on("TableResultByPageTOParent", function (event, msg) {
                $scope.$broadcast("TableResultByPage", msg);
            });
            $scope.$on("CreateModalTOParent", function (event, msg) {
                $scope.$broadcast("CreateModal", msg);
            });
        });

        //查询表单控制器
        app.controller("searchFormController", function ($scope, $http) {

            //初始化
            //初始化表单数据
            $scope.searchFormData = { // TODO modify here
                //如有需要 可以从服务器获取
                "dateRange": "*",
                "projName": "*",
                "projNo": "*"
            };
            //重置表单到默认状态
            $scope.setDefaultSearchFormData = function () {
                $scope.searchFormData = {
                    //如有需要 可以从服务器获取
                    "dateRange": "*",
                    "projName": "*",
                    "projNo": "*"

                };
                $scope.$emit("TableResultUpdateTOParent", undefined);
            };
            //提交表单操作
            $scope.submitSearchForm = function (page) {
                var sendData = jQuery.extend(true, {}, $scope.searchFormData);
                sendData["service"] = "listProj";
                if ($scope.searchFormData.dateRange != "*") {
                    var startDate, endDate;
                    var date = $scope.searchFormData.dateRange.split(" - ");
                    startDate = date[0];
                    endDate = date [1];

                    sendData["startDate"] = startDate;
                    sendData["endDate"] = endDate;
                }else{
                    sendData["startDate"] = "0000-01-01";
                    sendData["endDate"] = "9999-12-31";
                }
                if ($scope.searchFormData.projName == "*") {
                    sendData["projName"] = "";
                }
                if ($scope.searchFormData.projNo == "*") {
                    sendData["projNo"] = "";
                }
                sendData["pageNumber"] = page;

                //处理存放在 $scope.searchFormData 下的数据并发送到服务器
                console.log(sendData);
                $http.post(servletLocation, sendData).success(function (response) {  //TODO Modify the api & post info here
                    //获取到结果列表
                    console.log(response);
                    //将更新事件冒泡到父控制器
                    $scope.$emit("TableResultUpdateTOParent", messageHandler(response));
                });
            };
            $scope.$on("TableResultByPage", function (event, msg) {
                $scope.submitSearchForm(msg);
            });
        });

        //结果表格控制器
        app.controller("resultTableController", function ($scope, $http) {
            //载入表格结果
            $scope.$on("TableResultUpdate", function (event, msg) {
                console.log("resultTableController", msg);
                if (msg == undefined) {
                    $scope.resultTableData = msg;
                    return;
                }
                var pageNumberArray = [];
                for (var i = 1; i <= msg.totalPageNumber; i++) {
                    pageNumberArray.push(i.toString());
                }

                $scope.resultTableData = msg;
                $scope.resultTableData["pageNumberArray"] = pageNumberArray;
            });
            $scope.getResultByPage = function (page) {
                $scope.$emit("TableResultByPageTOParent", page);
            };

            $scope.createModal = function (view, modelDataId) {
                if (view == "prp") {
                    var sendData = {};
                    sendData["service"]="listPrp";
                    sendData["projId"]=modelDataId;

                    $http.post(servletLocation, sendData).success(function (response) {  //TODO Modify the api & post info here
                        //获取到结果列表
                        console.log(response);
                        response["modalType"] = view;
                        //将更新事件冒泡到父控制器
                        $scope.$emit("CreateModalTOParent", response);

                    });
                    return;
                }
                if(view == "add") {
                    var message = {};
                    message["modalType"] = view;
                    message["currentPage"] = $scope.resultTableData.pageNumber;
                    message["modelRange"] = {
                        "stateRange":[
                            {
                                "value":"运行中",
                                "displayName":"运行中"
                            },{
                                "value":"挂起",
                                "displayName":"挂起"
                            },{
                                "value":"关闭",
                                "displayName":"关闭"
                            }
                        ]
                    };

                    $scope.$emit("CreateModalTOParent", message);
                    return;
                }
                if(view=="emp"){
                	var sendData = {};
                    sendData["service"] = "listEmpPos";
                    sendData["projId"] = modelDataId;
                    $http.post(servletLocation,sendData).success(function (response) {  //TODO Modify the api & post info here
                        //获取到结果列表
                        console.log("empResponse");
                        console.log(response);
                        response["modalType"] = view;
                        //将更新事件冒泡到父控制器
                        $scope.$emit("CreateModalTOParent", response);
                    });
                    return;
                }
                
                var sendData = {};
                sendData["service"] = "detailProj";
                sendData["projId"] = modelDataId;
                $http.post(servletLocation,sendData).success(function (response) {  //TODO Modify the api & post info here
                    //获取到结果列表
                    console.log(response);
                    response["modalType"] = view;
                    //将更新事件冒泡到父控制器
                    $scope.$emit("CreateModalTOParent", response);
                });
            }
            
            //配置部门
            $scope.config_dep = function(proj_id){
            		$(".holyContainer").css("opacity", 0.2);
            		$(".config_dep_modal").css("display","none");
            		$(".config_dep_modal").css("display","");
            		$("#department-treeview").html("");
            		$.ajax({
            			type : "POST",
            			url : "/yangming_rms/depTree",
            			data : {
            				"service" : "searchDeps"
            			},
            			success : function(data) {
            				console.log(data);
            				var jsonData = eval('(' + data + ')');
            				if (jsonData.messageType == "success") {
            					var root = jsonData['response']['data'];
            					$.ajax({
                        			type : "POST",
                        			url : "/yangming_rms/servlet/ProjectServlet",
                        			data : {
                        				"service" : "listDep",
                        				"projId" : proj_id
                        			},
                        			success : function(select) {
                        				console.log(select);
                        				var select_data = eval('(' + select + ')');
                        				var select_ids = select_data['modelData']['selected'];
                        				
                    					var html = getTreeNodeBase(root,select_ids);
                           				$("#department-treeview").addClass("tree");
                       					$("#department-treeview").addClass("tree-unselectable");
                       					$("#department-treeview").attr("role", "tree");
                       					$("#department-treeview").html(html);
                    					
                       					$(".check_btn").on("click",function(){
                       						var isChecked = $(this).prop("checked");
                       						$(this).parent().parent().parent().parent().find(":checkbox").each(function(){
                   								$(this).prop("checked",isChecked);
                   							});   
                       						event.stopPropagation();
                       					});
                       					//click the tree node
                    					$(".tree-branch-header").on("click", function() {
                    						if($(this).attr("show") == "show"){
                    							$(this).attr("show","hide");
                    							$(this).siblings().each(function(){
                    								$(this).css("display","none");
                    							});
                    						}
                    						else if($(this).attr("show") == "hide"){
                    							$(this).attr("show","show");
                    							$(this).siblings().each(function(){
                    								$(this).css("display","");
                    							});
                    						}
                    					});
                       					//update the dep config
                       					$(".holyContainer").find("*").each(function() { 
                       						$(this).attr("disabled", "disabled"); 
                       					});
                       					$(".dep_congfig_close_btn").click(function(){
                       						$(".config_dep_modal").css("display","none");
                    						$(".holyContainer").css("opacity", 1);
                       						$(".holyContainer").find("*").each(function() { 
                       							$(this).removeAttr("disabled"); 
                       						});
                       					});
                       					$(".dep_congfig_submit_btn").click(function(){
                       						//提交配置项目部门
                       						var select_deps = [];
                       						$(".config_dep_modal input:checked").each(function(){
                       							select_deps.push($(this).val());
                       						});
                       						console.log(select_deps);
                       						
                       						$.ajax({
                                    			type : "POST",
                                    			url : "/yangming_rms/servlet/ProjectServlet",
                                    			data : {
                                    				"service" : "setDep",
                                    				"projId" : proj_id,
                                    				"list" : select_deps
                                    			},
                                    			success : function(select) {
                                    				//alert_div
                                    			}
                       						});
                       						$(".config_dep_modal").css("display","none");
                    						$(".holyContainer").css("opacity", 1);
                       						$(".holyContainer").find("*").each(function() { 
                       							$(this).removeAttr("disabled"); 
                       						});
                       					});
                        			}
            					});
            				}
            			}
            		}); 
            }
            
            getTreeNodeBase = function(data,ids){
            	var html = "<li class='tree-branch' role='treeitem' aria-expanded='false'> "
    				+ "<div class='tree-branch-header' show='show'>"
    				+"<div class='dep'>"
    				+ "<span class='tree-branch-name'> ";
            	var select = false;
            	for(var key in ids){
            		if((key == data['dep_id']) && (ids[key] == true)){
            			select = true;
            			break;
            		}
            	}
            	if(select)
            		html += "<input type='checkbox' value='"+data['dep_id']+"' checked='true' class='check_btn'>";
            	else
            		html += "<input type='checkbox' value='"+data['dep_id']+"' class='check_btn'>";	
    			html += "<i class='icon-folder ace-icon fa fa-folder "
    				+ getColor()
    				+ "'></i> "
    				+ "<span class='tree-label'>"
    				+ data['text']
    				+ "</span> "
    				+ "</span> "
    				+"</div>"
    				+ "</div>"
    				+ "<ul class='tree-branch-children' role='group'> ";
	    		var addition = data['additionalParameters'];
	    		if (addition) {
	    			var child = addition['children'];
	    			for ( var childNode in child) {
	    				html += getTreeNodeBase(child[childNode],ids);
	    			}
	    		}
	    		html += "</ul> " + "<div class='tree-loader hide' role='alert'> "
	    				+ "<div class='tree-loading'>"
	    				+ "<i class='ace-icon fa fa-refresh fa-spin blue'></i>"
	    				+ "</div> " + "</div> " + "</li>";
	    		return html;
            }
            function GetRandomNum(Min, Max) {
        		var Range = Max - Min;
        		var Rand = Math.random();
        		return (Min + Math.round(Rand * Range));
        	}
        	function getColor() {
        		var colors = [ 'red', 'orange', 'blue', 'green', 'black' ];
        		var num = GetRandomNum(1, 5);
        		return colors[num];
        	}

        });
        //Modal控制器
        app.controller("modalController", function ($scope, $http) {
            $scope.$on("CreateModal", function (event, msg) {
                loadDatePicker();
                $scope.modal = msg;
                $scope.modalOriginal = jQuery.extend(true, {}, msg);
                $scope.editFormShowInvalidInfo = false;
                $scope.editFormShowResult = false;
                $scope.addFormShowInvalidInfo = false;
                $scope.addFormShowResult = false;
                if($scope.modal.modalType == "emp"){
                	$scope.empModalInit();
                }
                
         
                $("#modal").modal('toggle');
            });

            $scope.submitEditModal = function (valid) {
                if (valid && $scope.editFormShowInvalidInfo) {
                    var sendData = {};
                    sendData["service"] = "editProj";
                    sendData["projId"] = $scope.modalOriginal.modelData.projId;
                    sendData["projNo"] = $scope.modal.modelData.projNo;
                    sendData["projName"] = $scope.modal.modelData.projName;
                    sendData["startDate"] = $scope.modal.modelData.startDate;
                    sendData["endDate"] = $scope.modal.modelData.endDate;
                    sendData["state"] = $scope.modal.modelData.state;
                    sendData["projDescription"] = $scope.modal.modelData.projDescription;

                    console.log(sendData);
                    $http.post(servletLocation, sendData).success(function (response) {  //TODO Modify the api & post info here
                        messageHandler(response);
                        if (response.returnMessage.messageType == "success") {
                            $("#modal").modal('toggle');
                            $scope.$emit("TableResultByPageTOParent", $scope.modal.currentPage);
                        }
                    });
                }
                if (valid) {
                    $scope.editFormShowResult = true;
                }
                $scope.editFormShowInvalidInfo = true;
            };

            $scope.submitDelModal = function () {
                var sendData = {};
                sendData["service"] = "delProj";
                sendData["projId"] = $scope.modalOriginal.modelData.projId;
                console.log(sendData);
                $http.post(servletLocation, sendData).success(function (response) {
                    messageHandler(response);
                    console.log(response);
                    if (response.returnMessage.messageType == "success") {
                        $scope.$emit("TableResultByPageTOParent", $scope.modal.currentPage);
                        $("#modal").modal('toggle');
                    }
                });
            };
            $scope.submitAddModal = function (valid) {
                if (valid && $scope.addFormShowInvalidInfo) {
                    var sendData = {};
                    sendData["service"] = "addProj";
                    sendData["projNo"] = $scope.modal.modelData.projNo;
                    sendData["projName"] = $scope.modal.modelData.projName;
                    sendData["startDate"] = $scope.modal.modelData.startDate;
                    sendData["endDate"] = $scope.modal.modelData.endDate;
                    sendData["projDescription"] = $scope.modal.modelData.projDescription;
                    console.log(sendData);
                    $http.post(servletLocation, sendData).success(function (response) {  //TODO Modify the api & post info here
                        messageHandler(response);
                        console.log(response);
                        if (response.returnMessage.messageType == "success") {
                            $scope.$emit("TableResultByPageTOParent", $scope.modal.currentPage);
                            $("#modal").modal('toggle');
                        }
                    });
                }
                if (valid) {
                    $scope.addFormShowResult = true;
                }
                $scope.addFormShowInvalidInfo = true;
            };
            $scope.submitPRPSelectModal = function () {
                var sendData = {};
                sendData["service"] = "setPrp";
                sendData["projId"] = $scope.modal.modelRange.projId;
                sendData["list"] = [];

                for (var key in $scope.modal.modelData.selectedRow) {
                    if ($scope.modal.modelData.selectedRow[key] == true) {
                        sendData["list"].push(Number(key));
                    }
                }
                console.log("sendData:");
                console.log(sendData);
                // array in angularjs... f@cking servlet
                $.ajax(
                        {
                            type: "post",
                            url: servletLocation,
                            data: sendData,
                            success: function (response) {
                                response = eval('(' + response + ')');
                                messageHandler(response);
                                if (response.returnMessage.messageType == "success") {
                                    $("#modal").modal('toggle');
                                }
                            }
                        }
                );
            }
            
            $scope.empModalInit = function() {
            	for(var key in $scope.modal.modelData) {
            		var enName = $scope.translateC2E(key)
            		if(enName!=null){
            			$scope.modal.modelData[enName] = $scope.modal.modelData[key];
            			delete $scope.modal.modelData[key];
            		}
            	}
            }
            
            $scope.submitEmpSelectModal = function () {
            	for(var key in $scope.modal.modelData) {
            		var cnName = $scope.translateE2C(key)
            		if(cnName!=null){
            			$scope.modal.modelData[cnName] = $scope.modal.modelData[key];
            			
            		}
            	}
            	var sendData = {};
                sendData["service"] = "setEmpPos";
                sendData["projId"] = $scope.modal.modelData.projId;
                sendData["pos"] =[];
                sendData["empId"] =[];
            	for(var key in $scope.modal.modelData) {
            		if($scope.translateC2E(key)!=null && $scope.translateC2E(key)!="tp"){
     
                        sendData["pos"].push(key);
                      	sendData["empId"].push($scope.modal.modelData[key]);
            		}
            	}    
            	for(var key in $scope.modal.modelData) {
            		if($scope.translateC2E(key)!=null && $scope.translateC2E(key)=="tp"){
     					for(var index in $scope.modal.modelData[key]) {
     						sendData["pos"].push(key);
                          	sendData["empId"].push($scope.modal.modelData[key][index]);
     					}
                        
            		}
            	}     
            			
            		
            	
            	console.log("sendData:");
                console.log(sendData);
                // array in angularjs... f@cking servlet
                  $.ajax(
                        {
                            type: "post",
                            url: servletLocation,
                            data: sendData,
                            success: function (response) {
                                response = eval('(' + response + ')');
                                messageHandler(response);
                                if (response.returnMessage.messageType == "success") {
                                    $("#modal").modal('toggle');
                                }
                            }
                        }
                );	 
            }
            
		
			$scope.translateE2C = function(englishName) {
				if(englishName == null || englishName == undefined){
					return null;
				}
				if(englishName=="pm"){
					return "项目经理";
				}
				if(englishName=="qa"){
					return "质量负责人";
				}
				if(englishName=="dp"){
					return "研发负责人";
				}
				if(englishName=="cp"){
					return "财务负责人";
				}
				if(englishName=="la"){
					return "法律/认证";
				}
				if(englishName=="mp"){
					return "市场负责人";
				}
				if(englishName=="vp"){
					return "验证负责人";
				}
				if(englishName=="pp"){
					return "生产负责人";
				}
				if(englishName=="ap"){
					return "应用负责人";
				}
				if(englishName=="bp"){
					return "采购负责人";
				}
				if(englishName=="sp"){
					return "服务负责人";
				}
				if(englishName=="tp"){
					return "参与人员";
				}
				return null;
				
			}
			$scope.translateC2E = function(chineseName) {
				if(chineseName == null || chineseName == undefined){
					return null;
				}
				if(chineseName=="项目经理"){
					return "pm";
				}
				if(chineseName=="质量负责人"){
					return "qa";
				}
				if(chineseName=="研发负责人"){
					return "dp";
				}
				if(chineseName=="财务负责人"){
					return "cp";
				}
				if(chineseName=="法律/认证"){
					return "la";
				}
				if(chineseName=="市场负责人"){
					return "mp";
				}
				if(chineseName=="验证负责人"){
					return "vp";
				}
				if(chineseName=="生产负责人"){
					return "pp";
				}
				if(chineseName=="应用负责人"){
					return "ap";
				}
				if(chineseName=="采购负责人"){
					return "bp";
				}
				if(chineseName=="服务负责人"){
					return "sp";
				}
				if(chineseName=="参与人员"){
					return "tp";
				}
				return null;
			}
        });

    });

</script>





